/*******************************************************************************
 * Copyright 2007, 2009 InnovaSoft SA http://www.innovasoft.biz/
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *       http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *******************************************************************************/

package biz.innovasoft.nodb.query;

import java.util.Date;

/**
 * This class helps the constructions of the QueryCriteria.
 * 
 * @author Diego Miranda
 *
 */
public class QueryCriteriaUtil {

	public static Where where (Expression expression) {
		return new Where (expression);
	}

 	public static Expression eq(String attr, String value) {
		return new Expression(attr, value);
	}
	
	public static Expression eq(String attr, Integer value) {
		return new Expression(attr, value);
	}
	
	public static Expression eq(String attr, Long value) {
		return new Expression(attr, value);
	}
	
	public static Expression eq(String attr, Date value) {
		return new Expression(attr, value);
	}
	
	public static Expression eq(String attr, Boolean value) {
		return new Expression(attr, value);
	}
	
	public static Expression not(Object value) {
		return new Expression(Operator.NOT, value);
	}

	public static Expression not(String attr, String value) {
		return new Expression(Operator.NOT, attr, value);
	}
	
	public static Expression not(String attr, Integer value) {
		return new Expression(Operator.NOT, attr, value);
	}
	
	public static Expression not(String attr, Long value) {
		return new Expression(Operator.NOT, attr, value);
	}
	
	public static Expression not(String attr, Date value) {
		return new Expression(Operator.NOT, attr, value);
	}
	
	public static Expression not(String attr, Boolean value) {
		return new Expression(Operator.NOT, attr, value);
	}

	public static Expression range(Object attr, String min, String max) {
		return new Expression(Operator.RANGE, attr, min, max);
	}
	
	public static Expression range(Object attr, Integer min, Integer max) {
		return new Expression(Operator.RANGE, attr, min, max);
	}
	
	public static Expression range(Object attr, Long min, Long max) {
		return new Expression(Operator.RANGE, attr, min, max);
	}
	
	public static Expression range(Object attr, Date min, Date max) {
		return new Expression(Operator.RANGE, attr, min, max);
	}

	public static Expression not(Expression expression) {
		return new Expression(Operator.NOT, expression);
	}

	public static Expression and(Expression expression) {
		return new Expression(Operator.AND, expression);
	}

	public static Expression or(Expression expression) {
		return new Expression(Operator.OR, expression);
	}

	public static MultinaryExpression and(Expression... expressions) {
		return new MultinaryExpression(Operator.AND, expressions);
	}

	public static MultinaryExpression or(Expression... expressions) {
		return new MultinaryExpression(Operator.OR, expressions);
	}

}
